<template>
	<view>
		<nav-bar></nav-bar>
		<view style="padding: 0 30px;">
			<view style="font-size: 20px;font-weight: 600;color: #000000;line-height: 28px;letter-spacing: 1px;">我想委托“第1园区”招商</view>
			<view style="margin-top:18px;">
				<view style="font-size: 12px;font-weight: 400;color: #000000;">
					<text style="color:#ED1A23;">*</text>
					你的联系方式
				</view>
				<view style="margin-top:12px;"><u--input placeholder="请输入联系方式" border="surround" v-model="temp.lianxifangshi"></u--input></view>
			</view>
			<view style="margin-top:18px;">
				<view style="font-size: 12px;font-weight: 400;color: #000000;">
					<text style="color:#ED1A23;">*</text>
					你的姓名
				</view>
				<view><u--input placeholder="你的姓名" border="surround" v-model="temp.xingming"></u--input></view>
			</view>
			<view style="margin-top:18px;">
				<view style="font-size: 12px;font-weight: 400;color: #000000;">
					<text style="color:#ED1A23;">*</text>
					你的园区
				</view>
				<view><u--input placeholder="你的园区" border="surround" v-model="temp.yuanqu"></u--input></view>
			</view>
			<view style="margin-top:23px;"><u-button type="primary" color="#FE7743" text="提交" @click="addContact"></u-button></view>
		</view>
		<!-- 测 -->
		<!-- <view style="padding: 50px;">宽度：{{ goWidth }}</view> -->
		<!-- 结 -->
	</view>
</template>

<script>
export default {
	data() {
		return {
			temp: {
				lianxifangshi: '',
				xingming: '',
				yuanqu: '',
				goWidth: ''
			}
		};
	},
	onShow() {
		uni.getSystemInfo({
			success: function(res) {
				console.log('屏幕宽度：' + res.screenWidth);
				console.log('屏幕高度：' + res.screenHeight);
				console.log('可使用窗口宽度：' + res.windowWidth);
				console.log('可使用窗口高度：' + res.windowHeight);
				let getDeviceInfo = uni.getDeviceInfo();
				// 获取设备基础信息
				console.log(getDeviceInfo);
				console.log('获取设备基础信息');
			}
		});
	},
	onLoad() {
		uni.getSystemInfo({
			success: function(res) {
				this.goWidth = res.windowHeight;
				console.log(res);
			}
		});
	},
	methods: {
		addContact() {
			if (this.temp.lianxifangshi == '') {
				return uni.showToast({
					title: '联系方式不能为空',
					icon: 'none',
					duration: 2000
				});
			}
			if (this.temp.xingming == '') {
				return uni.showToast({
					title: '姓名不能为空',
					icon: 'none',
					duration: 2000
				});
			}
			if (this.temp.yuanqu == '') {
				return uni.showToast({
					title: '园区不能为空',
					icon: 'none',
					duration: 2000
				});
			}
			let that = this;
			this.$apiCall.request(
				'post',
				'/woyaozhaoshang/add',
				{
					yuanquname: that.temp.yuanqu,
					xingming: that.temp.xingming,
					lianxifangshi: that.temp.lianxifangshi
				},
				{
					sucCb(data) {
						console.log(data);
						// uni.navigateBack();
						if (data.code === 0) {
							uni.showToast({
								title: data.msg,
								icon: 'none',
								duration: 2000
							});
							setTimeout(() => {
								uni.navigateBack();
							}, 1000);
						} else {
							uni.showToast({
								title: data.msg,
								icon: 'none',
								duration: 2000
							});
						}
						// uni.$u.toast(data.data.msg);
					}
				}
			);
		}
	}
};
</script>

<style lang="scss"></style>
